<style type="text/css">.errors{overflow:auto}</style>
<%- @view_title = "Administration" -%>
<div class="andare">
  <div class="heading">
    <h2>
      <%- if scope[:isNewRepo] %>Add <% else %>Edit <% end %>Package Repository<a class="help" href="<%= docs_url '/extension_points/package_repository_extension.html' %>" target="_blank">What is a Package Repository?</a>
    </h2>
  </div>
    <div id="package-repositories" class="layout admin-entity">
        <div class="navigation">
                <%= render :partial => 'list', :locals => {:scope => {:package_repositories => scope[:package_repositories], :current_repo => scope[:package_repository].getName(), :package_to_pipeline_map => scope[:package_to_pipeline_map]}} %>
        </div>
        <div class="content">

            <% if package_material_plugins.length < 2 %>
                <div class="information" style="margin: 0 !important;"> No plugins found. To configure a package repository you must have plugin(s) installed.</div>
            <%- end -%>
            <%= render :partial => "admin/shared/global_errors.html", :locals => {:scope => {}} -%>
            <div id="ajax_form_submit_errors" class="form_submit_errors">
            </div>
            <%= form_for scope[:package_repository], :as => "package_repository", :url => scope[:url], :html => {:method => scope[:method], :id => "package_repositories_edit_form"} do |f| %>
                <fieldset>
                    <div class="hidden">
                        <%= md5_field %>
                        <%= f.hidden_field com.thoughtworks.go.domain.packagerepository.PackageRepository::REPO_ID %>
                    </div>

                    <div class="field required">
                        <%= label_with_hint f, com.thoughtworks.go.domain.packagerepository.PackageRepository::NAME, 'Name', "Enter a globally unique name", "required" %>
                        <%= f.text_field com.thoughtworks.go.domain.packagerepository.PackageRepository::NAME, :class => 'important' -%>
                    </div>
                    <%= f.fields_for com.thoughtworks.go.domain.packagerepository.PackageRepository::PLUGIN_CONFIGURATION, scope[:package_repository].getPluginConfiguration() do |plugin_configuration_form| %>
                        <div class="field required">
                            <%= label_with_hint plugin_configuration_form, com.thoughtworks.go.domain.config.PluginConfiguration::ID, 'Type', "Choose from available plugins", "required" -%>
                            <%= plugin_configuration_form.select com.thoughtworks.go.domain.config.PluginConfiguration::ID, package_material_plugins, {:selected => scope[:package_repository].getPluginConfiguration().getId()}, {} -%>
                        </div>
                    <% end %>
                </fieldset>
                <div id="pluginConfigurations">
                     <%= render :partial => 'config', :locals => {:scope => {:repository_configuration => @repository_configuration, :plugin_id => scope[:package_repository].getPluginConfiguration().getId(), :isNewRepo => scope[:iSNewRepo]}} %>
                </div>
                <%= render :partial => 'shared/form_required_message.html', :locals => {:scope => {}} %>
                <div class="form_buttons">
                        <button type="submit" class="submit primary" id="submit_form"><span>SAVE</span></button>
                        <button type="reset" class="submit" id="reset_form"><span>RESET</span></button>
                </div>
            <% end %>
        </div>
        <%= render :partial => 'shared/convert_tool_tips.html', :locals => {:scope => {}} %>
    </div>
</div>
